package com.njwb.day15.zqzb.Age;

import org.apache.log4j.Logger;

public class TestPeople {
    public static Logger logger = Logger.getLogger("com.njwb.day15.zqzb.Age");
    public static void main(String[] args) {
        People p = new People();

        try {
            p.setAge(150);  // 故意设置错误年龄
            System.out.println("年龄设置成功，年龄为：" + p.getAge());
        } catch (AgeOutOfRangeException e) {
            System.out.println("发生异常：" + e.getMessage());
            logger.error("11112211");

        }

        try {
            p.setAge(30);  // 合理的年龄
            System.out.println("年龄设置成功，年龄为：" + p.getAge());
        } catch (AgeOutOfRangeException e) {
            System.out.println("发生异常：" + e.getMessage());
            logger.info("程序执行结束");
        }
    }
}
